package com.hao.wms.query;

import com.hao.wms.domain.OrderBill;
import com.hao.wms.util.DateUtil;

import java.util.Date;

public class OrderChartQueryObject extends QueryObject {
    private Date beginDate;
    private Date endDate;
    private Long supplierId = -1L;
    private String groupTpye = "EMPLOYEE";

    public Date getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Long getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(Long supplierId) {
        this.supplierId = supplierId;
    }

    public String getGroupTpye() {
        return groupTpye;
    }

    public void setGroupTpye(String groupTpye) {
        this.groupTpye = groupTpye;
    }

    @Override
    public void customerQuery() {
        if (beginDate != null) {
            addQuery("obj.bill.vdate >= ?", DateUtil.getBeginDate(beginDate));
        }
        if (endDate != null) {
            addQuery("obj.bill.vdate <= ?", DateUtil.getEndDate(endDate));
        }
        if (supplierId > 0) {
            addQuery("obj.bill.supplier.id = ?", supplierId);
        }
        addQuery("obj.bill.status = ?", OrderBill.AUDIT);
    }

}
